﻿using IterationLife.FootballTeaching.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.FootballTeachings {
    /// <summary>
    /// 球员位置数据传输对象扩展
    /// </summary>
    public static class PlayerPositionDtoExtension {
        /// <summary>
        /// 转换为球员位置实体
        /// </summary>
        /// <param name="dto">球员位置数据传输对象</param>
        public static PlayerPosition ToEntity( this PlayerPositionDto dto ) {
            if ( dto == null )
                return new PlayerPosition();
            return dto.MapTo( new PlayerPosition( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为球员位置数据传输对象
        /// </summary>
        /// <param name="entity">球员位置实体</param>
        public static PlayerPositionDto ToDto(this PlayerPosition entity) {
            if( entity == null )
                return new PlayerPositionDto();
            return entity.MapTo(new PlayerPositionDto());
        }
    }
}
